package com.ruoyi.smart.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.smart.domain.SmartProductTest;
import com.ruoyi.smart.service.ISmartProductTestService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产品测试Controller
 * 
 * @author minwei
 * @date 2022-06-20
 */
//@Api("产品测试")
@RestController
@RequestMapping("/smart/SmartProductTest")
public class SmartProductTestController extends BaseController
{
    @Autowired
    private ISmartProductTestService smartProductTestService;

    /**
     * 查询产品测试列表
     */
    //@ApiOperation("查询产品测试列表")
    @PreAuthorize("@ss.hasPermi('smart:SmartProductTest:list')")
    @GetMapping("/list")
    public TableDataInfo list(SmartProductTest smartProductTest)
    {
        startPage();
        List<SmartProductTest> list = smartProductTestService.selectSmartProductTestList(smartProductTest);
        return getDataTable(list);
    }

    /**
     * 导出产品测试列表
     */
    @PreAuthorize("@ss.hasPermi('smart:SmartProductTest:export')")
    @Log(title = "产品测试", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SmartProductTest smartProductTest)
    {
        List<SmartProductTest> list = smartProductTestService.selectSmartProductTestList(smartProductTest);
        ExcelUtil<SmartProductTest> util = new ExcelUtil<SmartProductTest>(SmartProductTest.class);
        util.exportExcel(response, list, "产品测试数据");
    }

    /**
     * 获取产品测试详细信息
     */
    //@ApiOperation("获取产品测试详细信息")
    @PreAuthorize("@ss.hasPermi('smart:SmartProductTest:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(smartProductTestService.selectSmartProductTestById(id));
    }

    /**
     * 新增产品测试
     */
    //@ApiOperation("新增产品测试")
    @PreAuthorize("@ss.hasPermi('smart:SmartProductTest:add')")
    @Log(title = "产品测试", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SmartProductTest smartProductTest)
    {
        return toAjax(smartProductTestService.insertSmartProductTest(smartProductTest));
    }

    /**
     * 修改产品测试
     */
    //@ApiOperation("修改产品测试")
    @PreAuthorize("@ss.hasPermi('smart:SmartProductTest:edit')")
    @Log(title = "产品测试", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SmartProductTest smartProductTest)
    {
        return toAjax(smartProductTestService.updateSmartProductTest(smartProductTest));
    }

    /**
     * 删除产品测试
     */
    //@ApiOperation("删除产品测试")
    @PreAuthorize("@ss.hasPermi('smart:SmartProductTest:remove')")
    @Log(title = "产品测试", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(smartProductTestService.deleteSmartProductTestByIds(ids));
    }
}
